package Utils;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JOptionPane;

import com.Logs;

import db.DebugText;
import db.IpList;
import db.fuxi;

public class Windows {
	
	public static void MessageBox(String str0){
		
		JOptionPane.showMessageDialog(null, str0);
		
	}
	
	public static void historycomBoxInit(JComboBox<String> jbox){
		
		
		List<DebugText> list = new ArrayList<DebugText>();
		list = fuxi.findAll(DebugText.class);
		
		for(DebugText debugText :  list){
			
			jbox.addItem(debugText.getPackageText()+"/"+debugText.getActivityText())  ;
		}
		
	}
public static void ipListcomBoxInit(JComboBox<String> jbox){
		
		
		List<IpList> list = new ArrayList<IpList>();
		list = fuxi.findAll(IpList.class);
		
		for(IpList ip :  list){
			
			jbox.addItem(ip.getIpName())  ;
		}
		
	}
	
 public  static  void execBat(String str0){
	 
	 String dictory = System.getProperty("user.dir");

	 File file = new File(dictory,"temp.bat");
	 
	 try{
	 if(!file.exists()){
		 
		 file.createNewFile();
	 }
	 
	 FileWriter fw = new FileWriter(file);
	 
	 fw.write(str0);
	 runCommand(file.toString());
	 fw.close();
	 }catch(Exception e){
		 
		 e.printStackTrace();
	 }
	 
	 
	 
 }
  public  static void runCommand(String command){
	  
	  try{
		  
		  Runtime.getRuntime().exec("cmd /c start "+command+" pause");
	  }catch(Exception e){
		  
		  e.printStackTrace();
	  }
	  
  }

}
